


clear all 
use the_dataset.dta

keep if  standard == 1

* Create globals to estimate
global covariates1 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1
global covariates2 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 
global covariates3 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 yeardummy1-yeardummy9



*1.1 Estimation T01
preserve
keep if case_1 == 1
* sdid
absdid culture_d, tvar(unemp) xvar($covariates3) sle 
eststo C1
matrix cul1_sp_m_est_ = e(b)
scalar cul1_sp_est_ = cul1_sp_m_est_[1,1]
*matching
teffects nnmatch (culture_d $covariates1) (unemp), ematch(CCAA1 ANOENC1) nneighbor(3) atet biasadj($covariates1)
matrix cul1_mm_m_est_ = e(b)
scalar cul1_mm_est_ = cul1_mm_m_est_[1,1]
eststo D1
* Trimmed
gen var = _n
merge 1:1 var using "trimmedt01.dta"
drop _merge
keep if (culture_1==1 | unemp==1)
teffects nnmatch (culture_d $covariates1) (unemp), ematch(CCAA1 ANOENC1) nneighbor(3) atet biasadj($covariates1)
matrix cul1_mmt_m_est_ = e(b)
scalar cul1_mmt_est_ = cul1_mmt_m_est_[1,1]
eststo G1
restore

*1.2 Estimation T12
preserve
keep if case_2 == 1
* sdid
absdid culture_d, tvar(unemp) xvar($covariates3) sle 
matrix cul2_sp_m_est_ = e(b)
scalar cul2_sp_est_ = cul2_sp_m_est_[1,1]
eststo E1
* matching
teffects nnmatch (culture_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
matrix cul2_mm_m_est_ = e(b)
scalar cul2_mm_est_ = cul2_mm_m_est_[1,1]
eststo F1
*Trimmed
gen var = _n
merge 1:1 var using  "trimmedt12.dta"
drop _merge
keep if (culture_2==1 | unemp==1)
teffects nnmatch (culture_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
matrix cul2_mmt_m_est_ = e(b)
scalar cul2_mmt_est_ = cul2_mmt_m_est_[1,1]
eststo H1
restore

*1.3 Income T01
preserve
keep if case_1==1
* SDID
absdid income_d, tvar(unemp) xvar($covariates3) sle 
eststo I1
matrix inc1_sp_m_est_ = e(b)
scalar inc1_sp_est_ = inc1_sp_m_est_[1,1]
* Matching
teffects nnmatch (income_d $covariates1) (unemp), ematch(CCAA1 ANOENC1) nneighbor(3) atet biasadj($covariates1)
eststo I2
matrix inc1_mm_m_est_ = e(b)
scalar inc1_mm_est_ = inc1_mm_m_est_[1,1]
* Trimmed
gen var = _n
merge 1:1 var using "trimmedt01.dta"
drop _merge
keep if (culture_1==1 | unemp==1)
teffects nnmatch (income_d $covariates1) (unemp), ematch(CCAA1 ANOENC1) nneighbor(3) atet biasadj($covariates1)
matrix inc1_mmt_m_est_ = e(b)
scalar inc1_mmt_est_ = inc1_mmt_m_est_[1,1]
restore

* income T12
preserve
keep if case_2==1
*Sdid
absdid income_d, tvar(unemp) xvar($covariates3) sle 
eststo I3
matrix inc2_sp_m_est_ = e(b)
scalar inc2_sp_est_ = inc2_sp_m_est_[1,1]
* matching
teffects nnmatch (income_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo I4
matrix inc2_mm_m_est_ = e(b)
scalar inc2_mm_est_ = inc2_mm_m_est_[1,1]
*Trimmed
gen var = _n
merge 1:1 var using  "trimmedt12.dta"
drop _merge
keep if (culture_2==1 | unemp==1)
teffects nnmatch (income_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
matrix inc2_mmt_m_est_ = e(b)
scalar inc2_mmt_est_ = inc2_mmt_m_est_[1,1]
restore

* TABLES

esttab C1 I1 C1 using spdid1.tex, b(a5) se(2) star(* 0.1 ** 0.05 *** 0.01) ///
mtitle ("Cultural Expenditure" "Income" "Elasticity" ) coeflabels ( r1vs0.unemp "Culture"  _cons "Culture" ) replace

esttab D1 I2 C1 using match1.tex, b(a5) se(2) star(* 0.1 ** 0.05 *** 0.01) ///
mtitle ("Cultural Expenditure" "Income" "Elasticity" ) coeflabels ( r1vs0.unemp "Culture"  _cons "Culture" ) replace

esttab G1 I2 C1 using t_match1.tex, b(a5) se(2) star(* 0.1 ** 0.05 *** 0.01) ///
mtitle ("Cultural Expenditure" "Income" "Elasticity" ) coeflabels ( r1vs0.unemp "Culture"  _cons "Culture" ) replace

esttab E1 I3 C1 using spdid2.tex, b(a5) se(2) star(* 0.1 ** 0.05 *** 0.01) ///
mtitle ("Cultural Expenditure" "Income" "Elasticity" ) coeflabels ( r1vs0.unemp "Culture"  _cons "Culture" ) replace

esttab F1 I4 C1 using match2.tex, b(a5) se(2) star(* 0.1 ** 0.05 *** 0.01) ///
mtitle ("Cultural Expenditure" "Income" "Elasticity" ) coeflabels ( r1vs0.unemp "Culture"  _cons "Culture" ) replace

esttab H1 I2 C1 using t_match2.tex, b(a5) se(2) star(* 0.1 ** 0.05 *** 0.01) ///
mtitle ("Cultural Expenditure" "Income" "Elasticity" ) coeflabels ( r1vs0.unemp "Culture"  _cons "Culture" ) replace


* Elasticity
* gen vectors
gen Inc1_sp_est_var = 0
gen Inc1_mm_est_var = 0
gen Inc1_mmt_est_var = 0

gen c1_sp_est_var = 0
gen c1_mm_est_var = 0
gen c1_mmt_est_var = 0

gen Inc2_sp_est_var = 0
gen Inc2_mm_est_var = 0
gen Inc2_mmt_est_var = 0

gen c2_sp_est_var = 0
gen c2_mm_est_var = 0
gen c2_mmt_est_var = 0

* replace vectors with coefficients
replace Inc1_sp_est_var = inc1_sp_est_
replace Inc2_sp_est_var = inc2_sp_est_

replace Inc1_mm_est_var = inc1_mm_est_
replace Inc2_mm_est_var = inc2_mm_est_

replace Inc1_mmt_est_var = inc1_mmt_est_
replace Inc2_mmt_est_var = inc2_mmt_est_

replace c1_sp_est_var = cul1_sp_est_
replace c2_sp_est_var = cul2_sp_est_

replace c1_mm_est_var = cul1_mm_est_
replace c2_mm_est_var = cul2_mm_est_

replace c1_mmt_est_var = cul1_mmt_est_
replace c2_mmt_est_var = cul2_mmt_est_

* gen average values
sum culture2 if case_1==1 & unemp==1
scalar c1 = r(mean)
sum culture2 if case_2==1 & unemp==1
scalar c2 = r(mean)

sum income2 if case_1==1 & unemp==1
scalar inc1 = r(mean)
sum income2 if case_2==1 & unemp==1
scalar inc2 = r(mean)

* gen new vectors
gen c_1 = 0
gen c_2 = 0

gen inc_1 = 0
gen inc_2 = 0

* replace new vectors with average values

replace c_1 = (2*c1)
replace c_2 = (2*c2)
replace inc_1 = (2*inc1)
replace inc_2 = (2*inc2)

* gen variations
gen own_elast_sp_c1 = c1_sp_est_var / (c_1 - c1_sp_est_var)
gen own_elast_mm_c1 = c1_mm_est_var / (c_1 - c1_mm_est_var)
gen own_elast_mmt_c1 = c1_mmt_est_var / (c_1 - c1_mmt_est_var)

gen own_elast_sp_c2 = c2_sp_est_var / (c_2 - c2_sp_est_var)
gen own_elast_mm_c2 = c2_mm_est_var / (c_2 - c2_mm_est_var)
gen own_elast_mmt_c2 = c2_mmt_est_var / (c_2 - c2_mmt_est_var)

gen own_elast_sp_inc1 = Inc1_sp_est_var / (inc_1 - Inc1_sp_est_var)
gen own_elast_mm_inc1 = Inc1_mm_est_var / (inc_1 - Inc1_mm_est_var)
gen own_elast_mmt_inc1 = Inc1_mmt_est_var / (inc_1 - Inc1_mmt_est_var)

gen own_elast_sp_inc2 = Inc2_sp_est_var / (inc_2 - Inc2_sp_est_var)
gen own_elast_mm_inc2 = Inc2_mm_est_var / (inc_2 - Inc2_mm_est_var)
gen own_elast_mmt_inc2 = Inc2_mmt_est_var / (inc_2 - Inc2_mmt_est_var)

* gen income elasticity
gen elast_sp_c1 = own_elast_sp_c1 / own_elast_sp_inc1
gen elast_mm_c1 = own_elast_mm_c1 / own_elast_mm_inc1
gen elast_mmt_c1 = own_elast_mmt_c1 / own_elast_mmt_inc1

gen elast_sp_c2 = own_elast_sp_c2 / own_elast_sp_inc2
gen elast_mm_c2 = own_elast_mm_c2 / own_elast_mm_inc2
gen elast_mmt_c2 = own_elast_mmt_c2 / own_elast_mmt_inc2

sum elast_sp_c1 elast_mm_c1 elast_mmt_c1 elast_sp_c2 elast_mm_c2 elast_mmt_c2
